/**
 * @function: 所有ACTION基类
 * @modify history
 * Date           Author            Description
 * --------------------------------------------------------
 * 2010/01/12     fan.kebin         Created
 *  
 */
package com.byxm.wlgw.control;

import java.util.ResourceBundle;

import com.byxm.wlgw.bean.SpxxBean;
import com.byxm.wlgw.common.Pages;
import com.byxm.wlgw.service.SpxxService;
import com.googlecode.jsonplugin.annotations.JSON;

import com.opensymphony.xwork2.ActionSupport;

public abstract class BaseAction extends ActionSupport {
	//default serialnumber
	private static final long serialVersionUID = 3701603986729403812L;
	
	/***配置图片服务器****/

		
	protected String G_MESSAGE_INFO;
	
	
	@JSON(serialize = false)

	public String getG_MESSAGE_INFO() {
		return G_MESSAGE_INFO;
	}

	public void setG_MESSAGE_INFO(String g_message_info) {
		G_MESSAGE_INFO = g_message_info;
	}
	
	
	
	
	
	
	/**
	 *获取商品信息Pages属性 
	 *author: kim
	 * @throws Exception 
	 * 
	 */
	public Pages getSpxxPages(SpxxBean spxxBean,int pageNum,String cpage) {
		SpxxService spxxService=new SpxxService();
		Pages page=new Pages();
		page.setPageNum(pageNum);
		page.setPageNumFin(pageNum);
		
		//记录总条数
		int jlzts=0;
		//每页数据条数
		//int pageNum=12;
		//设置一下当前页当前页
		page.setCpage(Integer.parseInt(cpage));
		
		try {
			jlzts=spxxService.getSpxxCount(spxxBean);
			if(jlzts<pageNum){
				page.setZys(1);//如果总条数小于每页总条数  总页数等于1
				page.setPageNum(jlzts);//设置每页显示多少
			}else if(jlzts%pageNum!=0){
				page.setZys((jlzts/pageNum)+1);
				if(Integer.parseInt(cpage)!=(jlzts/pageNum)+1){
					page.setPageNum(pageNum);
					
				}
				if(Integer.parseInt(cpage)==(jlzts/pageNum)+1){
					page.setPageNum(jlzts%pageNum);
				}
			}else if(jlzts%pageNum==0){
				page.setZys(jlzts/pageNum);
			}
			page.setJlzts(jlzts);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return page;
	}
	
	
	
}
